public class Powxn {
    public static double pow(double x, int n) {
        if (n == 0) return 1;
        if (n == 2) return x * x;
        if (n % 2 == 0) return pow(pow(x, n / 2), 2);
        else if (n > 0) return x * pow(pow(x, n / 2), 2);
        else return 1 / x * pow(pow(x, n / 2), 2);
        
    }

    public static double pow1(double x, int n) {
        
        double result = 1;
        for(int i=0;i<n;i++)
            result *=x;

        return result;
    }
    
    public static void main(String[] args) {
        long startTime = System.nanoTime();
        double result = pow(1.1,100000);
        long endTime = System.nanoTime();

        System.out.println((endTime - startTime));

        startTime = System.nanoTime();
        result = pow1(1.1,100000);
        endTime = System.nanoTime();
        System.out.println((endTime - startTime));        
    }
}